package com.haredot.mapper;

import com.haredot.dto.*;
import com.haredot.entity.User;
import com.haredot.vo.UserVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {

    User findById(Long id);

    User findByUsername(String username);

    List<BindPositionUserDto> findPositionRefUserId(@Param("userId") Long userId);

    List<BindOrganizationUserDto> findOrganizationRefUserId(@Param("userId") Long userId);

    int insert(UserVo userVo);

    int batchSaveOrganizationAndUser(@Param("userId") Long id, @Param("orgs")List<Long> orgs);

    int batchSavePositionAndUser(@Param("userId")Long id, @Param("positions")List<Long> positions);

    int update(UserVo userVo);

    int removeOrganizationByUserId(@Param("userId") Long id);

    int removePositionByUserId(@Param("userId")Long id);

    List<UserAdminDTO> findUsersByCondition(Map<String, Object> searchParams);

    int deleteById(Long id);

    List<BindUserRoleDto> findRolesRefUserId(Long userId);

    int removeRoleAndUserByUserId(Long userId);

    int batchSaveRoleAndUser(@Param("userId") Long userId, @Param("roles") List<Long> roles);

    /**
     * 根据用户名，查询权限信息
     * @param username
     * @return
     */
    List<PermissionGrantedAuthority> findAuthoritiesByUsername(String username) ;

    List<PermissionGrantedAuthority> findAllAuthorities();
}